// 数据服务接口
import { axios } from '@/utils/request';

/**
 * 修改
 * @params data
 * {
    {"appId":{"description":"应用id","type":"integer"}},
    {"datasetId":{"description":"数据集id","type":"integer"}},
    {"id":{"description":"$column.comments","type":"integer"}},
    {"serviceType":{"description":"类型1：自助数据集，2：物对象","type":"integer"}}
   }
 */
export function putAppdatasetinfo(data) {
  return axios({
    method: 'put',
    url: 'appdatasetinfo',
    headers: { auth: true },
    data
  })
}

/**
 * 删除
 * @params params
 * {
    {"ids":{"required":false,"type":"string"}},
    {"appId":{"required":false,"type":"integer"}}
   }
 */
export function deleteAppdatasetinfo(params) {
  return axios({
    method: 'delete',
    url: 'appdatasetinfo',
    headers: { auth: true },
    params
  })
}

/**
 * [SQL数据集] 使用SQL分页查询数据
 * @params data
 * {
    {"datasourceId":{"description":"数据源ID","type":"integer"}},
    {"pageNo":{"description":"分页页码, 1开始","type":"integer"}},
    {"pageSize":{"description":"每页显示数","type":"integer"}},
    {"parameters":{"description":"参数","type":"array"}},
    {"querySql":{"description":"查询sql","type":"string"}},
    {"sortField":{"description":"排序字段","type":"string"}},
    {"sortOrder":{"description":"排序规则, ascend: 升序, desend: 降序","type":"string"}}
   }
 */
export function postAppdatasetinfoApiDatahubSqlRecord(data) {
  return axios({
    method: 'post',
    url: 'appdatasetinfodatahub/sql/record',
    headers: { auth: true },
    data
  })
}

/**
 * 保存-应用批量授权数据集
 * @params data
 * {
    {"appId":{"description":"应用id","type":"integer"}},
    {"datasetIds":{"description":"数据集id","type":"string"}},
    {"serviceType":{"description":"类型1：自助数据集，2：物对象","type":"integer"}}
   }
 */
export function postAppdatasetinfoApp(data) {
  return axios({
    method: 'post',
    url: 'appdatasetinfo/app',
    headers: { auth: true },
    data
  })
}

/**
 * 保存-数据集批量授权应用
 * @params data
 * {
    {"appIds":{"description":"应用ids","type":"string"}},
    {"datasetId":{"description":"数据集id","type":"integer"}},
    {"serviceType":{"description":"类型1：自助数据集，2：物对象","type":"integer"}}
   }
 */
export function postAppdatasetinfoDataset(data) {
  return axios({
    method: 'post',
    url: 'appdatasetinfo/dataset',
    headers: { auth: true },
    data
  })
}

/**
 * 详情
 * @params params
 * {
    {"id":{"required":false,"type":"integer"}}
   }
 */
export function getAppdatasetinfoInfo(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/info',
    headers: { auth: true },
    params
  })
}

/**
 * 列表
 * @params params
 * 
 */
export function getAppdatasetinfoList(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/list',
    headers: { auth: true },
    params
  })
}

/**
 * 应用已授权分页列表
 * @params params
 * {
    {"pageNo":{"required":false,"type":"integer","default":1}},
    {"pageSize":{"required":false,"type":"integer","default":20}},
    {"appId":{"required":false,"type":"integer"}},
    {"condition":{"required":false,"type":"string"}},
    {"datasourceId":{"required":false,"type":"integer"}}
   }
 */
export function getAppdatasetinfoPageList(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/page/list',
    headers: { auth: true },
    params
  })
}

/**
 * 应用未授权分页列表
 * @params params
 * {
    {"pageNo":{"required":false,"type":"integer","default":1}},
    {"pageSize":{"required":false,"type":"integer","default":20}},
    {"appId":{"required":false,"type":"integer"}}
   }
 */
export function getAppdatasetinfoPageUnauthList(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/page/unauth/list',
    headers: { auth: true },
    params
  })
}

/**
 * 应用已授权物对象列表
 * @params params
 * {
    {"pageNo":{"required":false,"type":"integer","default":1}},
    {"pageSize":{"required":false,"type":"integer","default":20}},
    {"appId":{"required":false,"type":"integer"}},
    {"name":{"required":false,"type":"string"}},
    {"modelId":{"required":false,"type":"integer"}}
   }
 */
export function getAppdatasetinfoPageThingList(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/page/thing/list',
    params
  })
}

/**
 * 应用未授权物对象列表
 * @params params
 * {
    {"pageNo":{"required":false,"type":"integer","default":1}},
    {"pageSize":{"required":false,"type":"integer","default":20}},
    {"appId":{"required":false,"type":"integer"}},
    {"name":{"required":false,"type":"string"}},
    {"modelId":{"required":false,"type":"integer"}}
   }
 */
export function getAppdatasetinfoPageThingUnauthList(params) {
  return axios({
    method: 'get',
    url: 'appdatasetinfo/page/thing/unauth/list',
    params
  })
}
